﻿@using Enter.Admin.Enums
@model List<Enter.Admin.Entities.Setting>
@{
    ViewData["Title"] = "配置管理";
    var i = 0;
}
@section Styles {
}
@section Scripts {
    <script src="~/plugins/parsleyjs/dist/parsley.min.js"></script>
    <script src="~/plugins/parsleyjs/dist/i18n/zh_cn.extra.js"></script>
    <script src="~/plugins/parsleyjs/dist/i18n/zh_cn.js"></script>
    <script>
        var edit = function (from_id) {
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "@Url.Action("Index", "Setting")",
                data: $(from_id).serialize(),
                success: function (result) {
                    if (result.Success) {
                        show_alert('success', result.Message)
                    } else {
                        show_alert('warning', result.Message)
                    }
                },
                error: function (e) {
                    show_alert('error', '网络异常.')                    
                }
            });
        }
        $(document).ready(function () {
            $('#form-save-button-1').click(function () {
                edit("#form-setting-1");
            })
            $('#form-save-button-2').click(function () {
                edit("#form-setting-2");
            })
        });
    </script>
}
<div class="profile-content">

    <!-- begin nav-tabs -->
    <ul class="nav nav-tabs">
        <li class="nav-item">
            <a href="#default-tab-1" data-toggle="tab" class="nav-link active">
                <span class="d-sm-none">Tab 1</span>
                <span class="d-sm-block d-none">邮箱配置</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="#default-tab-2" data-toggle="tab" class="nav-link">
                <span class="d-sm-none">Tab 2</span>
                <span class="d-sm-block d-none">同步文件配置</span>
            </a>
        </li>
    </ul>
    <!-- end nav-tabs -->
    <!-- begin tab-content -->
    <div class="tab-content">
        <!-- begin tab-pane -->
        <div class="tab-pane fade active show" id="default-tab-1">
            <!-- begin table -->
            <form asp-action="Index" id="form-setting-1">
                <table class="table table-profile">
                    <tbody>
                        @{
                            i = 0;
                        }
                        @foreach (var item in Model.Where(t => t.SettingType == EnumSettingType.邮件设置))
                        {
                            <tr>
                                <td style="vertical-align:middle;">@item.Display @(item.Key.EndsWith(":Enable")?"(true / false)":"")</td>
                                <td>
                                    <div class="input-group">
                                        <input type="text" name="data[@i][Id]" style="display:none" value="@item.Id" />
                                        <input type="text" name="data[@i][Value]" class="form-control" value="@item.Value" />
                                    </div>
                                </td>
                            </tr>
                            i++;
                        }
                        <tr class="divider">
                            <td colspan="2"></td>
                        </tr>
                        <tr class="highlight">
                            <td class="field">&nbsp;</td>
                            <td class="p-t-10 p-b-10">
                                <input id="form-save-button-1" type="button" class="btn btn-primary width-150" value="保存" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>
            <!-- end table -->
        </div>
        <!-- end tab-pane -->
        <!-- begin tab-pane -->
        <div class="tab-pane fade" id="default-tab-2">
            <form asp-action="Index" id="form-setting-2">
                <table class="table table-profile">
                    <tbody>
                        @{
                            i = 0;
                        }
                        @foreach (var item in Model.Where(t => t.SettingType == EnumSettingType.阿里云OSS设置))
                        {
                            <tr>
                                <td style="vertical-align:middle;">@item.Display @(item.Key.EndsWith(":Enable")?"(true / false)":"")</td>
                                <td>
                                    <div class="input-group">
                                        <input type="text" name="data[@i][Id]" style="display:none" value="@item.Id" />
                                        <input type="text" name="data[@i][Value]" class="form-control" value="@item.Value" />
                                    </div>
                                </td>
                            </tr>
                            i++;
                        }
                        <tr class="divider">
                            <td colspan="2"></td>
                        </tr>
                        <tr class="highlight">
                            <td class="field">&nbsp;</td>
                            <td class="p-t-10 p-b-10">
                                <input id="form-save-button-2" type="button" class="btn btn-primary width-150" value="保存" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>
        </div>
        <!-- end tab-pane -->
    </div>
    <!-- end tab-content -->
</div>